package com.example.basic.core.foreignData;


import com.example.basic.core.result.ResultCode;

import java.util.Date;

/**
 * 响应结果生成工具
 */
public class ForeignDataResultGenerator {
    private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";

    public static <T> ForeignDataResult<?> genSuccessResult() {
        return new ForeignDataResult<T>()
                .setCode(ResultCode.SUCCESS)
                .setMessage(DEFAULT_SUCCESS_MESSAGE);
    }

    public static <T> ForeignDataResult<T> genSuccessResult(T data, Date lastDatetime) {
        return new ForeignDataResult<T>(data)
                .setCode(ResultCode.SUCCESS)
                .setMessage(DEFAULT_SUCCESS_MESSAGE);
    }

    public static <T> ForeignDataResult<?> genFailResult(String message) {
        return new ForeignDataResult<T>()
                .setCode(ResultCode.FAIL)
                .setMessage(message);
    }
}
